package ljl.alg.jianzhioffer.round3.medium;

public class _44_findNthDigit {

    class lufei {

        public int findNthDigit(int n) {
            long start = 1;
            long count = 9;
            int digit = 1;
            while (n > count) {
                n -= count;
                digit++;
                start *= 10;
                count = 9 * digit * start;
            }
            long num = start + (n - 1) / digit;
            return Long.toString(num).charAt((n - 1) % digit) - '0';
        }
    }

}
